#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSerialPort>
#include <QtDebug>
#include <QSerialPortInfo>
#include <QByteArray>
#include <QTextCursor>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    //button
    void btn_open_port(bool);
    void btn_send_data(bool);
    void btn_clear_window(bool);
    void btn_close_port(bool);
    void btn_scan_port(bool);
    //save data
    void readData();
    QStringList scanSerial(); // 扫描可用串口

    void on_save_text_textChanged();

private:
    Ui::MainWindow *ui;
    /*-------function--------------*/
    void system_init();
    /*-------variable--------------*/
    QSerialPort global_port;
    QSerialPortInfo global_port_info;
    QTextCursor cursor;
};
#endif // MAINWINDOW_H
